package com.liao.liaowenlong.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.widget.Toast;

import com.liao.liaowenlong.service.UserDB2;

public class MyReceiver3 extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String username = intent.getStringExtra("username");
        String password = intent.getStringExtra("password");
        UserDB2 userDB2 = new UserDB2(context);
        SQLiteDatabase db = userDB2.getReadableDatabase();
        Cursor user = db.query("user", null, "username=? and password=?",
                new String[]{username, password}, null, null, null);
        if (user != null && user.getCount() > 0) {
            user.close();
            Toast.makeText(context, "登录成功", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(context, "登录失败", Toast.LENGTH_SHORT).show();
        }
    }
}
